package com.room.search.web.rest;

import com.room.search.core.page.TableDataInfo;
import com.room.search.response.RoomResult;
import com.room.search.service.RoomListingFeatureService;
import com.room.search.service.dto.RoomListingFeatureDTO;
import io.swagger.annotations.ApiModelProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * REST controller for managing {@link com.room.search.domain.RoomListingFeature}.
 */
@RestController
@CrossOrigin
@RequestMapping("/api")
public class RoomListingFeatureResource {

    private final Logger log = LoggerFactory.getLogger(RoomListingFeatureResource.class);


    private final RoomListingFeatureService roomListingFeatureService;

    public RoomListingFeatureResource(RoomListingFeatureService roomListingFeatureService) {
        this.roomListingFeatureService = roomListingFeatureService;
    }

    /**
     * 获取所有房源特色
     */
    @ApiModelProperty("获取所有房源特色")
    @GetMapping("/feature/list")
    public TableDataInfo getAllFeature(RoomListingFeatureDTO dto) {
        return roomListingFeatureService.getAllFeature();
    }

    @ApiModelProperty("添加房源特色")
    @PostMapping("/feature_add")
    public RoomResult addFeature(@RequestBody RoomListingFeatureDTO dto) {
        return roomListingFeatureService.addFeature(dto);
    }

    @ApiModelProperty("根据id获取房源特色")
    @GetMapping("/feature/{featureId}")
    public RoomResult getFeatureById(@PathVariable Long featureId) {
        return roomListingFeatureService.getFeatureById(featureId);
    }

    @ApiModelProperty("修改房源特色")
    @PutMapping("/feature_edit")
    public RoomResult editFeature(@RequestBody RoomListingFeatureDTO dto) {
        return roomListingFeatureService.editFeature(dto);
    }

    @ApiModelProperty("删除房源特色")
    @DeleteMapping("/feature_del/{id}")
    public RoomResult delFeature(@PathVariable Long id) {
        roomListingFeatureService.delete(id);
        return RoomResult.success("删除成功");
    }

}
